<include file="theme/functions"/>
<include file="public@head"/>
</head>
<body>
<div class="layui-fluid wrap" id="component-tabs">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">模板设计</div>
                <div class="layui-card-body">
                    <div class="layui-tab">
                        <ul class="layui-tab-title">
                            <li>
                                <a href="{:url('theme/fileSetting',['file_id'=>$file_id,'tab'=>'widget'])}">
                                    组件
                                </a>
                            </li>
                            <notempty name="file.more.vars">
                                <li>
                                    <a href="{:url('theme/fileSetting',['file_id'=>$file_id,'tab'=>'var'])}">
                                        设置
                                    </a>
                                </li>
                            </notempty>
                            <notempty name="has_public_var">
                                <li class="layui-this">
                                    <a href="{:url('theme/fileSetting',['file_id'=>$file_id,'tab'=>'public_var'])}">
                                        全局设置
                                    </a>
                                </li>
                            </notempty>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <form method="post" class="layui-form js-ajax-form" action="{:url('theme/settingPost')}">
                                    <foreach name="files" item="file">
                                        <if condition="$file.id neq $file_id">
                                            <notempty name="file['more']['vars']">
                                                {:_parse_vars($file.more.vars,'files['.$file['id'].'][vars]',1,'',$file['id'])}
                                                <else/>
                                            </notempty>
                                        </if>
                                    </foreach>
                                    <div class="layui-form-item layui-layout-admin">
                                        <div class="layui-input-block">
                                            <div class="layui-footer" style="left: 0;display: none;">
                                                <input type="hidden" name="id" value="{$file.id}">
                                                <button type="submit" class="layui-btn js-ajax-submit" id="submit-btn" data-success="successCallback">
                                                    {:lang('SAVE')}
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<include file="theme/scripts"/>
<script>
    function successCallback(data, statusText, xhr, $form) {
        function _refresh() {
            if (data.url) {
                //返回带跳转地址
                window.location.href = data.url;
            } else {
                if (data.code == 1) {
                    //刷新当前页
                    reloadPage(window);
                }
            }
        }

        layer.msg(data.msg, {time: 2000 ,offset: '100px'}, function(){
            if (parent.afterSaveSetting) {
                parent.afterSaveSetting();
            }
            _refresh();
        });
    }
</script>
</body>
</html>